<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="微社区,Q生活" name="keywords"/>
<meta content="微社区,Q生活" name="description"/>
<title>微社区|Q生活</title>
<link rel="stylesheet" href="${ctx }/static/css/Master.css"/>
<link rel="stylesheet" href="${ctx }/static/css/lq.datetimepick.css"/>

<script src="${ctx }/static/js/jquery-1.9.0.min.js"></script>
<script src="${ctx }/static/js/simpletooltip.min.js"></script>
<script src="${ctx }/static/js/selectUi.js"></script>
<script src="${ctx}/static/plugins/My97DatePicker/WdatePicker.js"></script>

<script src="${ctx}/static/plugins/layer/layer.js"></script>
<%-- 基础js,所有页面都需要引入此js,依赖layer.js --%>
<script src="${ctx}/static/js/common/base.js"></script>
<script src="${ctx}/static/js/common/util.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	LQ.selectUi.show({id:"normal"});
});

//启用/停用
function doEnableOrDisable(id,normal,name){
	var msg = '确认'+(normal==1?'停用':'启用')+'"'+name+'"吗?';
	top.layer.confirm(msg, {icon: 3}, function(index){
		$.ajax({    
		    url:"${ctx}/group/"+id+"/"+normal+"/updateToEnableOrDisable",   
		    data:"",    
		    type:"get",    
		    cache:false,    
		    dataType:"json",
		    async:true, //默认为true 异步    
		    success:function(data) {
	            top.layer.msg(data,{},function(){
		        	window.location.reload();   
	            });
		     }  
		});
	});
}

//删除
function del(id,name) {
	top.layer.confirm('确认删除"'+name+'"吗?', {icon: 3}, function(index){
		$.ajax({    
		    url:"${ctx}/group/"+id+"/delete",   
		    data:"",    
		    type:"get",    
		    cache:false,    
		    dataType:"json",
		    async:true, //默认为true 异步    
		    success:function(data) {    
	            top.layer.msg(data,{},function(){
		        	window.location.reload();   
				});
		     }  
		});
	});
    
}
</script>
</head>

<body class="utilSubmit">
<section class="boxRight">
<form id="searchForm" method="get" >
	<div class="context boxborder">
	
		<!-- 查询 -->
		<div class="SearchList">
			<ul class="clearfix">
				<li><span class="name">编号：</span><span class="pt"><input type="text" id="groId" name="groId" value="${result.entity.groId }" class="utilInteger"/></span></li>
				<li><span class="name">群组名：</span><span class="pt"><input type="text" id="groName" name="groName" value="${result.entity.groName }"/></span></li>
				<li><span class="name">状态： </span>
					<div id="normal" class="selectul" style="width: 85px;"><div class="selectfocus" data-value="${result.entity.normal}"><em></em></div><select>
					<option value="">请选择</option>
					<c:forEach items="${diy:getDicList('NORMAL') }" var="dic">
					<option value="${dic.code }">${dic.content }</option>
					</c:forEach>
					</select></div>
				</li>
				<li><span class="name">时间：</span><span class="date"><input type="text" placeholder="开始时间" id="dateStart" name="dateStart" value="${result.entity.dateStart }" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'dateEnd\')}'})"/></span>
						<span class="fg">~</span><span class="date"><input type="text" placeholder="结束时间" id="dateEnd" name="dateEnd" value="${result.entity.dateEnd }" onclick="WdatePicker({minDate:'#F{$dp.$D(\'dateStart\')}'})"/></span></li>
				<li class="combtn pr"><a href="javascript:void(0);" onclick="submitPage(1,this);" class="utilSubmitBtn">查询</a><a href="javascript:void(0);" class="utilReset">重置</a> </li>
			</ul>
		</div>
		
		<!-- 顶部按钮 -->
		<shiro:hasPermission name="users:group:create">
		<div class="pr prlink"><a href="${ctx}/group/create"><span class="icon j_icon"></span>新增群组</a></div>
		</shiro:hasPermission>
		
		<!-- 内容 -->
		<div class="com_table">
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<th>序号</th>
					<th>编号</th>
					<th>群组名</th>
					<%--<th>备注</th>--%>
					<th>拥有用户</th>
					<th>拥有角色</th>
					<th>拥有资源</th>
					<th>状态</th>
					<th>创建时间</th>
					<%--<th>创建人</th>
					<th>最后修改时间</th>
					<th>最后修改人</th>--%>
					<th>操作</th>
				</tr>
				<c:forEach items="${result.entityList}" var="group" varStatus="status">
				<tr>
					<td>${(result.currentPage-1)*result.pageSize+status.count}</td>
					<td>${group.groId}</td>
					<td>${group.groName}</td>
                	<%--<td>
                		<div class="utilTips">
							${group.groDesc.length()>10?group.groDesc.substring(0,10).concat(" ..."):group.groDesc}
							<c:if test="${group.groDesc.length()>10}">
							<div class="utilTipsText" style="display: none;">${group.groDesc}</div>
							</c:if>
						</div>
                	</td>--%>
                	<td>
		            	<div class="utilTips">
							${group.userNames.length()>15?group.userNames.substring(0,15).concat(" ..."):group.userNames}
							<c:if test="${group.userNames.length()>15}">
	                		<div class="utilTipsText" style="display: none;">${group.userNames}</div>
	                		</c:if>
						</div>
                	</td>
					<td>
                		<div class="utilTips">
							${group.rolNames.length()>15?group.rolNames.substring(0,15).concat(" ..."):group.rolNames}
							<c:if test="${group.rolNames.length()>15}">
	                		<div class="utilTipsText" style="display: none;">${group.rolNames}</div>
	                		</c:if>
						</div>
					</td>
					<td>
                		<div class="utilTips">
							${group.resourceNames.length()>15?group.resourceNames.substring(0,15).concat(" ..."):group.resourceNames}
							<c:if test="${group.resourceNames.length()>15}">
	                		<div class="utilTipsText" style="display: none;">${group.resourceNames}</div>
	                		</c:if>
						</div>
					</td>
					<td>${diy:keyToValue(group.normal,'NORMAL')}</td>
					<td>
						<div class="utilTips">
							<pretty:prettyTime date="${group.insertDate}"/>
	                		<div class="utilTipsText" style="display: none;"><fmt:formatDate value="${group.insertDate}" pattern="yyyy-MM-dd HH:mm:ss" /></div>
						</div>
					</td>
					<%--<td>${group.insertName }</td>
					<td><fmt:formatDate value="${group.lastUpdateDate}" pattern="yyyy-MM-dd" /></td>
					<td>${group.lastUpdateName }</td>--%>
					<td>
						<shiro:hasPermission name="users:group:view">
						<a class="icon micon_9" title="详情" href="${ctx}/group/${group.groId}/detail"></a>
						</shiro:hasPermission>
						<%--<a class="icon micon_7" title="管理成员" href="javascript:void(0);"></a>--%>
						<shiro:hasPermission name="users:group:update">
                        <a class="icon micon_2" title="编辑" href="${ctx}/group/${group.groId}/update"></a>
	                    </shiro:hasPermission>
	                    <shiro:hasPermission name="users:group:start/stop">
						<c:if test="${group.normal == 1}">
	                    <a class="icon micon_1" title="停用" href="javascript:void(0);" onclick="doEnableOrDisable('${group.groId}',${group.normal},'${group.groName}')"></a>
	                    </c:if>
	                    <c:if test="${group.normal == 0}">
	                    <a class="icon micon_12" title="启用" href="javascript:void(0);" onclick="doEnableOrDisable('${group.groId}',${group.normal},'${group.groName}')"></a>
	                    </c:if>
	                    </shiro:hasPermission>
	                    <shiro:hasPermission name="users:group:delete">
	                       <a class="icon micon_20" title="删除" href="javascript:void(0);" onclick="del('${group.groId}','${group.groName }');" ></a>
	                    </shiro:hasPermission>
					</td>
				</tr>
				</c:forEach>
			</table>
			<%-- 分页 --%>
			<%@ include file="/WEB-INF/common/page.jsp"%>
		</div>
	</div>
</form>
</section>
</body>
</html>
